package com.example.socket.server;

import com.example.exception.collar.NotOnlineException;

import javax.websocket.Session;
import java.io.IOException;

/**
 * @author w
 */
public class WebSocketUtil {
    public static void sendUser(String ip,String msg) throws IOException, NotOnlineException {
        Session session = WebSocketServer.onlineSessions.get(ip);
        if (session!=null){
            session.getBasicRemote().sendText(msg);
        }else {
            throw new NotOnlineException(ip+"不在线，消息发送异常");
        }
    }
}
